/*
 * Copyright 2011 Subhabrata Ghosh <subho.ghosh at langene.net>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */



package net.langene.nlp.model;

//~--- non-JDK imports --------------------------------------------------------

import net.langene.nlp.Context;
import net.langene.nlp.model.en.POS;

//~--- classes ----------------------------------------------------------------

/**
 *
 * @author Subhabrata Ghosh <subho.ghosh at langene.net>
 */
public abstract class AbstractPOS {

    /**
     * Get the POS name.
     *
     * @return
     */
    public abstract String name();

    /**
     * Get the integer value associated with the POS.
     *
     * @return
     */
    public abstract int value();

    /**
     * Get the Abstract POS type associated with the
     * current POS.
     * 
     * @return 
     */
    public abstract EnumPosType type();

    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof AbstractPOS)) {
            return false;
        }

        // Values shouldn't be compared across sub-classes.
        if (!this.getClass().equals(obj.getClass())) {
            return false;
        }

        return (value() == ((AbstractPOS) obj).value());
    }

    /**
     * Create a new instance of a POS object based on the 
     * current language and the passed word and POS string.
     * 
     * @param word Word
     * @param pos POS string
     * @return
     * @throws Exception 
     */
    public static AbstractPOS parse(String word, String pos) throws Exception {
        String	lang = Context.get().getLanguage();

        if (lang.equals("en")) {
            return new POS(pos, word);
        }

        throw new Exception("Unsupported Language [" + lang + "]");
    }
}


//~ Formatted by Jindent --- http://www.jindent.com
